<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<title>layui</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet"
	th:href="@{/manager/layui/lib/layui-v2.5.5/css/layui.css}"
	href="../../lib/layui-v2.5.5/css/layui.css" media="all">
<link rel="stylesheet" th:href="@{/manager/layui/css/public.css}"
	href="../../css/public.css" media="all">
<style>
body {
	background-color: #ffffff;
}
</style>
</head>
<body>
	<div class="layui-form layuimini-form">
		<input type="hidden" name="id" th:value="${menu != null}  ? ${menu.id} ">
		<div class="layui-form-item">
			<label class="layui-form-label required">菜单名称</label>
			<div class="layui-input-inline">
				<input type="text" name="name" lay-verify="required"
					th:value="${menu != null}  ? ${menu.name} " lay-reqtext="菜单名称不能为空"
					placeholder="请输入菜单名称" class="layui-input">

			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label required">父菜单</label>
			<div class="layui-input-inline">
				<input type="text" lay-verify="required" id="parentvalue" placeholder="请选择父级菜单"
					readonly="readonly" class="layui-input" th:value="${pmenu != null}  ? ${pmenu.name}:'顶级菜单'">
					<input type="hidden" id="parentId" name="parentId" th:value="${menu != null}  ? ${menu.parentId}:'-1' ">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label required">菜单url</label>
			<div class="layui-input-inline">
				<input type="text" name="url" lay-verify="required"
					th:value="${menu != null}  ? ${menu.url}" lay-reqtext="菜单URL不能为空"
					placeholder="请输入菜单URL" class="layui-input">

			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label required">类型</label>
			<div class="layui-input-inline">
				<input type="radio" name="type" value="0" title="目录" th:checked="${menu != null}  ? (${menu.type==0} ? 'checked':false) : true "  checked="checked">
				<input type="radio" name="type" value="1" title="菜单" th:checked="${menu != null}  ? (${menu.type==1} ? 'checked':false) : false " >
				<input type="radio" name="type" value="2" title="按钮" th:checked="${menu != null}  ? (${menu.type==2} ? 'checked':false) : false " >
				<input type="radio" name="type" value="3" title="导航菜单" th:checked="${menu != null}  ? (${menu.type==3} ? 'checked':false) : false " >
<!-- 				<input type="radio" name="type" value="0" title="目录" th:field="${menu != null}  ? (${menu.type != null} ? ${menu.type}:0) : 0 "  checked> -->
<!-- 				<input type="radio" name="type" value="1" title="菜单" th:field="${menu != null}  ? (${menu.type != null} ? ${menu.type}:1) : 1 "> <input -->
<!-- 					type="radio" name="type" value="2" title="按钮" th:field="${menu != null}  ? (${menu.type != null} ? ${menu.type}:2) : 2 "> <input -->
<!-- 					type="radio" name="type" value="3" title="导航菜单" th:field="${menu != null}  ? (${menu.type != null} ? ${menu.type}:3) : 3 "> -->
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label required">是否跳转</label>
			<div class="layui-input-inline">
				<input type="radio" name="isBlank" value="1" title="否" checked th:value="${menu != null}  ? (${menu.isBlank != null} ? ${menu.isBlank}:'1') : '1'">
				<input type="radio" name="isBlank" value="0" title="是" th:value="${menu != null}  ? (${menu.isBlank != null} ? ${menu.isBlank}:'0') : '0'">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label required">是否可见</label>
			<div class="layui-input-inline">
				<input type="radio" name="visible" value="0" title="是" checked th:value="${menu != null}  ? (${menu.visible != null} ? ${menu.visible}:'0') : '0'">
				<input type="radio" name="visible" value="1" title="否"  th:value="${menu != null}  ? (${menu.visible != null} ? ${menu.visible}:'1') : '1'">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">排序</label>
			<div class="layui-input-inline">
				<input type="text" name="orderNum" class="layui-input"
					th:value="${menu != null}  ? ${menu.orderNum}">
			</div>
		</div>


		<div class="layui-form-item">
			<div class="layui-input-block">
				<button class="layui-btn layui-btn-normal" lay-submit
					lay-filter="saveBtn">确认保存</button>
			</div>
		</div>
	</div>
	
	
	
	<!-- 	</form> -->
	<script th:src="@{/manager/layui/lib/layui-v2.5.5/layui.js}"
		src="../../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
	<script>
		layui.use([ 'form'], function() {
			var form = layui.form, layer = layui.layer, $ = layui.$;
			//监听提交
			form.on('submit(saveBtn)', function(data) {
				$.ajax({
					url : '/menu/add',
					data : data.field,
					dataType : "json",
					success : function(result) {
						layer.alert("操作成功", function() {
							parent.window.location.reload();
						})

					}
				});

				return false;
			});

			
			$("#parentvalue").click(function() {
				layer.open({
					title : '选择上级菜单',
					type : 2,
					area : [ '40%', '80%' ],
					fixed : false, //不固定
					maxmin : true,
					content : '/menu/totreelist'
// 					content : '/manager/menu/treelist.html'
				});

			});
		
			

		});
	</script>
</body>
</html>